<template>
  <div class="risk">
    <!-- <div class="add" @click="edit()">新增设备设施</div> -->
    <van-search class="info_search" v-model="value" placeholder="搜索" />
    <van-list
      style="margin-top: 10px"
      :finished="finished"
      v-model="loading"
      finished-text="没有更多了"
    >
      <van-cell v-for="(item, index) in list" :key="index">
        <van-card
          title=""
          :thumb="baseUrl + item.Attachs"
          @click="handleClick(item)"
        >
          <template #desc>
            <div style="margin-top: 10px">证书名称：{{ item.CertName }}</div>
            <div>证书类型：{{ item.CertTypeName }}</div>
          </template>
        </van-card>
        <van-tag v-if="item.CertKind == 'Company'" class="tags" type="warning"
          >公司证书</van-tag
        >
        <van-tag v-if="item.CertKind == 'Sys'" class="tags" type="warning"
          >系统证书</van-tag
        >
      </van-cell>
    </van-list>
  </div>
</template>

<script>
import { certList } from "@/api/cert";
export default {
  data() {
    return {
       id:this.$route.query.id,
      baseUrl: process.env.VUE_APP_BASE_API,
      active: 0,
      value: "",
      list: [],
      selectKey: "",
      filter: {},
      loading: false,
      finished: false,
    };
  },
  created() {
    this.getList();
  },
    	beforeRouteLeave(to, from, next) {
		to.params.id =this.$route.query.id,

		next() //继续下一步
	},
  methods: {
    getList() {
      this.loading = true;
      certList(this.filter).then((res) => {
        this.loading = false;
        this.finished = true;
        this.list = res.data;
        this.filter.page = res.data;
      });
    },
    // 设备详情
    handleClick(item) {
      this.$router.push({
        name: "CertEdit",
        params: { name: item.CertName, code: item.CertCode,type: item.CertTypeName,id:this.id },
      });
    },
  },
};
</script>

<style lang="less">

.risk {
  height: 100vh;
  background-color: #e8f1f8;
  .info_search {
    padding: 10px;
    border-radius: 5px !important;
    .van-field__control {
      background-color: #ffffff !important;
    }
  }
}
.all_dep {
  background-color: #ffffff;
}
.warn_item {
  margin: 10px;
  /*margin-bottom: 10px;*/
  padding: 10px 0 10px 10px;
  border-radius: 5px;
  position: relative;
}
.warn_header {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 10px;
  .warn_tag {
    position: absolute;
    right: 0;
    top: 0;
    border-radius: 26.64rem 0 0 26.64rem;
  }
}
.dep_sort {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
  img {
    height: 15px;
    width: 15px;
    margin-right: 5px;
  }
}
.dep_btm {
  display: flex;
  justify-content: flex-end;
  .btm_item {
    display: flex;
    align-items: center;
    img {
      height: 15px;
      width: 15px;
      margin-right: 5px;
    }
  }
}

.tags {
  position: absolute;
  right: 0;
  top: 0;
  border-radius: 26.64rem 0 0 26.64rem;
}
</style>
